# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=benchmark
pkgver=1.9.0
pkgrel=1
pkgdesc="microbenchmark support library"
url="https://github.com/google/benchmark"
arch="all"
license="Apache-2.0"
makedepends="cmake doxygen gtest-dev samurai"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/google/benchmark/archive/v$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		_cmake_crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF \
		-DBENCHMARK_ENABLE_DOXYGEN=ON \
		-DBENCHMARK_ENABLE_LTO=ON \
		-DBENCHMARK_ENABLE_WERROR=OFF \
		-DBENCHMARK_USE_BUNDLED_GTEST=OFF \
		$_cmake_crossopts .
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
0e91e0e5a2222d7650fd8bd9cafb2f0e7c1689cd1b87b2cc529c738db12bfef31162aa5a4da78f7b0aa7f0101dc08b626802c58d39862458f82f9fea9316ca25  benchmark-1.9.0.tar.gz
"
